<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <div class="section">
                <h1>Visualizando</h1>
                <h:form id="formCustomer">
                    <p:growl id="msg" life="3000"/>
                    <div class="container_24 clearfix">

                        <p:panel header="Dados Gerais" id="panelDados" >
                            <p:outputLabel value="Nome:" styleClass="grid_3" for="name" />
                            <p:inputText styleClass="grid_19 ajustInput" readonly="true"
                                         id="name" value="#{managerSearchCustomer.showCustomer.name}" />


                            <p:outputLabel value="Cpf:" styleClass="grid_3" for="cpf" />
                            <p:inputMask mask="999.999.999-99" required="true" requiredMessage="Campo CPF é obrigatório" 
                                         readonly="true"
                                         id="cpf" styleClass="grid_8" value="#{managerSearchCustomer.showCustomer.cpf}" />
                            <p:outputLabel value="Rg:" styleClass="grid_3" />
                            <p:inputText styleClass="grid_8" maxlength="12" 
                                         readonly="true" value="#{managerSearchCustomer.showCustomer.rg}" />


                            <p:outputLabel value="Sexo:" styleClass="grid_3"/>
                            <p:inputText styleClass="grid_8" readonly="true"
                                         value="#{managerSearchCustomer.showCustomer.gender}" />

                            <p:outputLabel value="Profissão:" styleClass="grid_3" /> 
                            <p:inputText styleClass="grid_8" readonly="true"
                                         value="#{managerSearchCustomer.showCustomer.profession}" />

                            <div class="clear-both" />

                            <p:outputLabel value="Nacionalidade:" styleClass="grid_3 nationalityLabel" />
                            <p:inputText styleClass="grid_8" readonly="true" value="#{managerSearchCustomer.showCustomer.nationality}"/>
                            <p:outputLabel value="Estado Civil:" styleClass="grid_3 civilStatusLabel"/>
                            <p:inputText styleClass="grid_8" readonly="true" 
                                         value="#{managerSearchCustomer.showCustomer.civilStatus}" />

                            <p:outputLabel value="Data Nasc.:" styleClass="grid_3 dataNascLabel"  />
                            <p:inputText styleClass="grid_8" readonly="true" id="dataNasc"
                                        value="#{managerSearchCustomer.showCustomer.dateOfBirth}">
                                <f:convertDateTime parent="dd/MM/yyyy" />
                            </p:inputText>
                            <p:outputLabel value="Telefone:" styleClass="grid_3"  />
                            <p:inputMask mask="(99)9999-9999" styleClass="grid_8" readonly="true"
                                         value="#{managerSearchCustomer.showCustomer.fixedPhone}" />

                            <p:outputLabel value="Celular:" styleClass="grid_3" />
                            <p:inputMask mask="(99)9999-9999" styleClass="grid_8" readonly="true"
                                         value="#{managerSearchCustomer.showCustomer.celPhone}" />
                            <p:outputLabel value="Email:" styleClass="grid_3" />
                            <p:inputText styleClass="grid_8" readonly="true"
                                         value="#{managerSearchCustomer.showCustomer.email}" />
                            <div class="clear"/>
                        </p:panel>
                        <br/>

                      

                        <p:panel id="endereco" header="Endereço">



                            <p:dataTable id="tableAdd" var="address" value="#{managerSearchCustomer.addresses}" 
                                         styleClass="grid_24"
                                         rowIndexVar="rowid"
                                         emptyMessage="Nenhum registro">  
                                <f:facet name="header">
                                    Endereço
                                </f:facet>
                                <p:column headerText="Rua" width="300">  
                                    <h:outputText value="#{address.patio}"/>
                                </p:column>  
                                <p:column headerText="Bairro">  
                                    <h:outputText value="#{address.district}"/>
                                </p:column>
                                <p:column headerText="Tipo">  
                                    <h:outputText value="#{address.typeAddress}"/>
                                </p:column>

                               
                            </p:dataTable>
                            <div class="clear"/>
                        </p:panel>


                        <br/>
                        <p:panel header="Cônjuge" id="panelConj" 
                                 rendered="#{managerSearchCustomer.showCustomer.civilStatus.name eq 'CASADO'}">

                            <p:outputLabel value="CPF:" styleClass="grid_3"  />
                            <p:inputMask id="conjCpf" mask="999.999.999-99" styleClass="grid_8" 
                                         value="#{managerSearchCustomer.conjugue.cpf}">

                            </p:inputMask>
                            <div class="clear-both"/>
                            <p:outputLabel  value="Nome :" styleClass="grid_3" />
                            <p:inputText id="conjNome" styleClass="grid_19 ajustInput"
                                         value="#{managerSearchCustomer.conjugue.name}" />


                            <p:outputLabel  value="RG:" styleClass="grid_3" />
                            <p:inputText  id="conjRg" styleClass="grid_8" maxlength="12" 
                                          value="#{managerSearchCustomer.conjugue.rg}" />
                            <p:outputLabel value="Contato:" styleClass="grid_3 dataNascLabel"  />
                            <p:inputMask mask="(99)9999-9999" styleClass="grid_8" 
                                         value="#{managerSearchCustomer.conjugue.celPhone}" />
                            <div class="clear"/>
                        </p:panel>

                        <p:panel header="Anexo">
                            <ui:repeat  value="#{managerSearchCustomer.annexs}" var="a">

                                <h:outputLink  
                                    value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.descricao}"  
                                    target="_blank" >

                                    <div style="text-align: center; width: 20%;" class="grid_4">

                                        <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                        style="margin-left:1%; width: 100px;"
                                                        url="show/?annex=#{a.id}" />

                                        <p:outputLabel  value="#{a.descricao.length() ge 10 ? a.descricao.substring(0, 10).concat('...') : 
                                                                 a.descricao.replace('.png','').replace(' ','_')}" 
                                                        style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                        <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                        style="margin-left:1%; width: 100px;" 
                                                        url="assets/images/pdf.jpeg" />

                                        <p:outputLabel  value="#{a.descricao.length() ge 10 ? a.descricao.substring(0, 10).concat('...') : 
                                                                 a.descricao.replace('.pdf','').replace(' ','_')}" 
                                                        style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>
                                    </div>
                                    <f:param name="annex" value="#{a.id}"/>
                                </h:outputLink>

                            </ui:repeat>
                            <div class="clear"/>
                        </p:panel>

                        <div class="buttonAction">


                            <p:button value="Voltar"
                                      href="searchcustomer.xhtml"
                                      icon="ui-icon-arrowreturnthick-1-w"/>
                        </div>
                    </div>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
